package com.quinn.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 周汉坤
 */
public class ExcelListener<T> extends AnalysisEventListener<T> {


    //创建list集合封装最终的数据

    private List<T> list = new ArrayList<T>();

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
//一行一行去读取excle内容

    @Override

    public void invoke(T user, AnalysisContext analysisContext) {

        System.out.println("***" + user);
        this.list.add(user);

    }

    //读取excel表头信息

    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {

        System.out.println("表头信息：" + headMap);

    }

    //读取完成后执行

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
